# -*- coding: utf-8 -*-
"""
 @Time    : 2021/1/19 下午6:43
 @Author  : tgy
 
"""
from collections import namedtuple
import heapq

def test01():
    ...
    Person = namedtuple('person', ['name', 'age'])
    per = Person('zhangsan', 21)
    print(per.age)


def test02(records):
    ...
    Stock = namedtuple('Stock', ['name', 'shares', 'price'])
    all_price = 0
    for record in records:
        stock = Stock(*record)
        all_price += (stock.price)
    return all_price


def test03():
    Person = namedtuple('Person', ['name', 'age'])

    # per = Person('zhangsan',21)
    per = Person(name='tony', age=21)
    # per.age = 31
    pp = per._replace(age=31)
    print(pp)

def all_any():
    """
    all: iterator中每个元素的 bool(e)都为True才为True，其他都是False
    any: iterator中有一个元素的 bool(e)为True则为True，其他都是False
    """
    if all([True, True]):
        print('111')
    else:
        print('222')

if __name__ == '__main__':
    ...
    # test01()
    # res = test02([('zhangsan', '122', 23), ('lisi', '234', 45)])
    # print(res)
    test03()
    print(type(heapq))
    all = 1
    for num in heapq.nlargest(3, [-100,-98,-1,2,3,4]):
        ...
        all *= num
    print(all)

